package com.yphone.ui.dialog;


import android.app.Dialog;
import android.content.Context;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.WindowManager.LayoutParams;

import com.yphone.tools.base.IInitView;
import com.yphone.ui.dialog.inf.IFloat;
import com.yphone.utils.ScreenUtils;


public abstract class BaseDialog extends Dialog implements IFloat, IInitView {
    public BaseDialog(Context context) {
        super(context);
        requestWindowFeature(1);
        init();
    }

    public BaseDialog(Context context, int theme) {
        super(context, theme);
        requestWindowFeature(1);
        init();
    }

    public void init() {
        if (VERSION.SDK_INT < 19 || VERSION.SDK_INT >= 24) {
            getWindow().setType(2002);
        } else {
            getWindow().setType(2005);
        }
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initDataBeforView();
        initView();
        initListener();
        initData();
    }

    public void show() {
        super.show();
    }

    public void dismiss() {
        super.dismiss();
    }

    public void addFloat() {
        if (!isShowing()) {
            show();
        }
    }

    public void removeFloat() {
        if (isShowing()) {
            dismiss();
        }
    }

    public void initDataBeforView() {
        LayoutParams lp = getWindow().getAttributes();
        getWindow().setGravity(17);
        lp.width = ScreenUtils.getScreenWidth();
        getWindow().setAttributes(lp);
    }
}